{% extends "base.html" %}
{% block content %}
<section>
  <h1 class="p-name p-summary">James' Index Log</h1>
  <h2>About the crawl</h2>
  <p>{{ index_stats["total_pages_indexed"] }} pages and {{ index_stats["total_images_indexed"] }} images have been indexed in total.</p>
  <p>{{ index_stats["pages_indexed_in_last_crawl"] }} pages and {{ index_stats["images_indexed_in_last_crawl"] }} images were indexed in the last crawl.</p>
  <p>{{ index_stats["errors_found"] }} issues were found in the last crawl.</p>
  <p>jamesg.blog was last crawled at {{ index_stats["last_index_end"] }}. The last crawl lasted {{ index_stats["crawl_duration"] }}.</p>
</section>
<section>
  <h2>Find an issue by type</h2>
  <form action="/log" method="GET" role="search">
    <label for="issue_search">Search for issues by type:</label><br>
    <select name="issue_search" id="issue_search">
      <option value="all">All issues</option>
      {% for error_type in unique_error_types %}
      <option value="{{ error_type[0] }}" {% if error_type[0] == issue_search %}selected{% endif %}>{{ error_type[0] }}</option>
      {% endfor %}
    </select>
    <input type="submit" value="Search">
  </form>
</section>
<section>
  <h2>Crawl issue overview</h2>
  <p>Here is an overview of the issues found in the last crawl:</p>
  <ul>
    {% for error in issue_breakdown %}
    <li>{{ error[1].strip(".") }}: {{ error[0] }} issues.</li>
    {% endfor %}
  </ul>
  </ol>
</section>
<section>
  <h2>Crawl issues</h2>
  {% if results | length > 0 %}
    <hr>
    <ol>
        {% for r in range(0, results | length) %}
        <li>
          <p class="p-name"><a href="{{ results[r][0] }}" class="u-url">{{ results[r][0] }}</a> ({{ results[r][1] }})</p>
          <p class="p-summary">{{ results[r][2] }}</p>
          <p>Discovered: {% if results[r][3].startswith("https://") or results[r][3].startswith("http://") %}<a href="{{ results[r][3] }}">{{ results[r][3] }}</a>{% else %}{{ results[r][3] }}{% endif %}</p>
        </li>
        <hr>
        {% endfor %}
    </ol>
  {% else %}
    <p>No issues were found in the last crawl.</p>
  {% endif %}
</section>
{% endblock %}